<html>
<head><meta charset="utf-8"><title>Typecheck tables using Places · t-compiler/wg-rfc-2229 · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/index.html">t-compiler/wg-rfc-2229</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html">Typecheck tables using Places</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="201692794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201692794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201692794">(Jun 23 2020 at 06:57)</a>:</h4>
<p>typechk depends on rustc_middle for ty. rustc_middle::Ty is responsible for defining the <code>TypeckTables</code>. Now the <code>TypeckTables</code> would depend on rustc_typeck Place etc. </p>
<p>I thought about moving the Place, PlaceBase, etc. along with UpvarPath/Id definitions from librustc_middle  to rustc_hir because there counterparts for mir are defined in rustc_mir. However we depend on <code>rustc_middle::ty::Ty</code> for   the type information.  This would look somthing like <a href="https://github.com/sexxi-goose/rust/commit/c942ee4d9c06adc6f1c76ecedeb82c059f474320">this</a> ( I later realised that Ty coming from rustc_middle).</p>
<p>hir equivalent of <code>Ty</code> seems a bit more simpler and I'm not sure if there is something that connects those two dots easily.</p>
<p>I think librustc_middle/hir might be the place to move, though I'm not sure what exactly is it's purpose compared to librustc_hir, it seems like it supports the hir() queries.</p>



<a name="201772686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201772686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201772686">(Jun 23 2020 at 19:42)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span>  what do you think is the best place to move Place and related structs and enums so as to remove the circular dependency</p>



<a name="201772843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201772843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201772843">(Jun 23 2020 at 19:44)</a>:</h4>
<p>I would probably move to rustc_middle</p>



<a name="201772865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201772865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201772865">(Jun 23 2020 at 19:44)</a>:</h4>
<p>it's true that the MIR equivalents are defined alongside the MIR, but that is partly because they are <em>used in</em> the MIR</p>



<a name="201772887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201772887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201772887">(Jun 23 2020 at 19:44)</a>:</h4>
<p>i.e., to construct MIR, you build places</p>



<a name="201772897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201772897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201772897">(Jun 23 2020 at 19:44)</a>:</h4>
<p>whereas the HIR place is used for analysis of the HIR afterwards</p>



<a name="201772948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201772948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201772948">(Jun 23 2020 at 19:45)</a>:</h4>
<p>I'm not sure what <em>subdirectory</em> makes sense</p>



<a name="201772964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201772964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201772964">(Jun 23 2020 at 19:45)</a>:</h4>
<p>What's the purpose of rustc_middle/hir?</p>



<a name="201772998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201772998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201772998">(Jun 23 2020 at 19:45)</a>:</h4>
<p>people have been moving things around and I'm not 100% sure what ended up where, let me look</p>



<a name="201773198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201773198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201773198">(Jun 23 2020 at 19:46)</a>:</h4>
<p>OK</p>



<a name="201773201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201773201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201773201">(Jun 23 2020 at 19:46)</a>:</h4>
<p>well</p>



<a name="201773274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201773274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201773274">(Jun 23 2020 at 19:47)</a>:</h4>
<p>I <em>think</em> it defines some details about HIR that aren't available in librusc_hir yet</p>



<a name="201773281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201773281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201773281">(Jun 23 2020 at 19:47)</a>:</h4>
<p>e.g., the query providers</p>



<a name="201773316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201773316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201773316">(Jun 23 2020 at 19:47)</a>:</h4>
<p>I'm not sure if there's a good diagram or something that shows all the current rustc crates, it'd be a nice thing to have</p>



<a name="201773370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201773370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201773370">(Jun 23 2020 at 19:48)</a>:</h4>
<p>but in any case librustc_middle is where the rustc queries are defined</p>



<a name="201773389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201773389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201773389">(Jun 23 2020 at 19:48)</a>:</h4>
<p>so anything it depends on can't use queries</p>



<a name="201773393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201773393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201773393">(Jun 23 2020 at 19:48)</a>:</h4>
<p>Yeah, I'm not sure if it makes sense to define analysis structs there and impleent them in typeck</p>



<a name="201773404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201773404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201773404">(Jun 23 2020 at 19:48)</a>:</h4>
<p>it does</p>



<a name="201773407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201773407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201773407">(Jun 23 2020 at 19:48)</a>:</h4>
<p>that's the common pattern</p>



<a name="201773438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201773438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201773438">(Jun 23 2020 at 19:48)</a>:</h4>
<p>basically, things that have to be in the inputs/outputs from queries <em>have</em> to go in librustc_middle</p>



<a name="201773465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201773465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201773465">(Jun 23 2020 at 19:49)</a>:</h4>
<p>well or in some dependency of it, so that it can access them</p>



<a name="201773516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201773516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201773516">(Jun 23 2020 at 19:49)</a>:</h4>
<p>I think it would be ok to put the place definitions and the like in hir/place.rs or something</p>



<a name="201773550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201773550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201773550">(Jun 23 2020 at 19:49)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Circular.20Dependency/near/201773438">said</a>:</p>
<blockquote>
<p>basically, things that have to be in the inputs/outputs from queries <em>have</em> to go in librustc_middle</p>
</blockquote>
<p>That's fair</p>



<a name="201912838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201912838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201912838">(Jun 24 2020 at 22:45)</a>:</h4>
<p>I think for <a href="https://github.com/rust-lang/rust/pull/72591/files#diff-b9ef879826d6f88fc687506d6bbf9ceaL889">this here</a> we need  ClosureCaptures to be an IndexMap(at the very least IndexSet).</p>
<p>We can construct an upvar id easier isntead of the within the match and then use <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckTables.html#structfield.upvar_capture_map"><code>typeck_tables::upvar_capture_map</code></a> to see if we capture that id, but we would still need an index <a href="https://github.com/rust-lang/rust/pull/72591/files#diff-b9ef879826d6f88fc687506d6bbf9ceaR978">here</a></p>



<a name="201913557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201913557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201913557">(Jun 24 2020 at 22:55)</a>:</h4>
<p>Actually we can't do that because the same variable hir_id is assocaited with multiple PlaceWithHirId and we would need sort of a multimap</p>



<a name="201914020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201914020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201914020">(Jun 24 2020 at 23:00)</a>:</h4>
<p>We need a better way to index actually because <code>let y = || foo(p.x, p.y)</code> will have same var_hir_id pointing to definition of <code>p</code></p>



<a name="201914745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201914745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201914745">(Jun 24 2020 at 23:09)</a>:</h4>
<p>We also want to be smart about which PlaceWithHirId we keep for the the same Place, eg:</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">bar</span><span class="p">(</span><span class="n">x</span>: <span class="nb">String</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">println</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;{}&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">x</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nb">String</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">println</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;{}&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">x</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">format</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;Something&quot;</span><span class="p">);</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">foo</span><span class="p">(</span><span class="o">&amp;</span><span class="n">x</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">bar</span><span class="p">(</span><span class="n">x</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>

<span class="w">    </span><span class="n">c</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="n">println</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;{}&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">x</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="201914937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201914937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201914937">(Jun 24 2020 at 23:12)</a>:</h4>
<p>Nvm those will be two places, because of the ref</p>



<a name="201919875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/201919875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#201919875">(Jun 25 2020 at 00:21)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/201912838">said</a>:</p>
<blockquote>
<p>We can construct an upvar id easier isntead of the within the match and then use <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckTables.html#structfield.upvar_capture_map"><code>typeck_tables::upvar_capture_map</code></a> to see if we capture that id, but we would still need an index <a href="https://github.com/rust-lang/rust/pull/72591/files#diff-b9ef879826d6f88fc687506d6bbf9ceaR978">here</a></p>
</blockquote>
<p>We would the index <a href="https://github.com/sexxi-goose/rust/blob/c3dc8c455cee65db8928913da029725046c14a1b/src/librustc_mir_build/hair/cx/expr.rs#L978">here</a> *</p>



<a name="202028129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202028129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202028129">(Jun 25 2020 at 21:35)</a>:</h4>
<p>uh...ok... so you're saying "we need to define an ordering"</p>



<a name="202028131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202028131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202028131">(Jun 25 2020 at 21:35)</a>:</h4>
<p>I agree</p>



<a name="202028137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202028137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202028137">(Jun 25 2020 at 21:35)</a>:</h4>
<p>FxIndexSet seems fine</p>



<a name="202028166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202028166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202028166">(Jun 25 2020 at 21:35)</a>:</h4>
<p>I guess before we didn't need an ordering because we get a vec of free vars and <em>that</em> was the ordering?</p>



<a name="202028177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202028177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202028177">(Jun 25 2020 at 21:35)</a>:</h4>
<p>we could also use a <code>Vec</code> and do linear search</p>



<a name="202028185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202028185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202028185">(Jun 25 2020 at 21:35)</a>:</h4>
<p>but a <code>FxIndexSet</code> is probably better</p>



<a name="202028272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202028272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202028272">(Jun 25 2020 at 21:36)</a>:</h4>
<p>I'm concerned from a perf prespective (when using Vec) and also with FixedIndexSet, there might be issues if the same place is entered twice. In case of WithHirId, it won't matter but when it's just the raw Place it might have some impact</p>



<a name="202028659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202028659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202028659">(Jun 25 2020 at 21:40)</a>:</h4>
<p>What is the key in the set?</p>



<a name="202028682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202028682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202028682">(Jun 25 2020 at 21:40)</a>:</h4>
<p>Vec perf is probably faster except for really large closures .. but then potentially much slower :)</p>



<a name="202028689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202028689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202028689">(Jun 25 2020 at 21:40)</a>:</h4>
<p>depends how much we actually do "lookups by key"</p>



<a name="202028724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202028724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202028724">(Jun 25 2020 at 21:40)</a>:</h4>
<p>anyway I would use a <code>FxIndexSet</code></p>



<a name="202028744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202028744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202028744">(Jun 25 2020 at 21:40)</a>:</h4>
<p>but I don't quite understand the concern about the same place being entered twice</p>



<a name="202028791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202028791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202028791">(Jun 25 2020 at 21:41)</a>:</h4>
<p>Would it not affect the associated indecies?</p>



<a name="202028905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202028905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202028905">(Jun 25 2020 at 21:42)</a>:</h4>
<p>When I insert the same place the second time, it will switch the index over associated with the second insert.</p>



<a name="202029252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202029252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202029252">(Jun 25 2020 at 21:45)</a>:</h4>
<p>I'm not sure how index set handles that, but you can always check if it is already present</p>



<a name="202029275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202029275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202029275">(Jun 25 2020 at 21:45)</a>:</h4>
<p>I <em>think</em> if you overwrite an existing key though the index doesn't change</p>



<a name="202029446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202029446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202029446">(Jun 25 2020 at 21:47)</a>:</h4>
<p><a href="https://docs.rs/indexmap/1.4.0/indexmap/set/struct.IndexSet.html#method.insert">docs here</a></p>



<a name="202029447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202029447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202029447">(Jun 25 2020 at 21:47)</a>:</h4>
<p>The that's used so is either UpvarId{ closure_def_id, var_id} or var_hir_id</p>



<a name="202029465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202029465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202029465">(Jun 25 2020 at 21:47)</a>:</h4>
<blockquote>
<p>If an equivalent item already exists in the set, it returns false leaving the original value in the set and without altering its insertion order. Otherwise, it inserts the new item and returns true.</p>
</blockquote>



<a name="202029555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202029555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202029555">(Jun 25 2020 at 21:48)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/202029447">said</a>:</p>
<blockquote>
<p>The that's used so is either UpvarId{ closure_def_id, var_id} or var_hir_id</p>
</blockquote>
<p>This would cause conficts if we have two places that have the same variable hir id</p>



<a name="202030004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202030004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202030004">(Jun 25 2020 at 21:53)</a>:</h4>
<p>So if I understand correctly </p>
<div class="codehilite"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Point</span><span class="w"> </span><span class="p">{</span><span class="n">x</span>: <span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">y</span>: <span class="mi">10</span><span class="p">,</span><span class="w"> </span><span class="n">z</span>: <span class="mi">20</span><span class="p">};</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="n">println</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;{} {}&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">p</span><span class="p">.</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="n">p</span><span class="p">.</span><span class="n">y</span><span class="p">);</span><span class="w"></span>
</code></pre></div>


<p>If hir_id of the deifinition of p is <code>hir_p</code>, then the place for <br>
p.x -&gt; { expr_id, PlaceBase::Upvar_id(closure_hir, hir_p), {Deref, Field(x)} }<br>
p.y -&gt; { expr_id, PlaceBase::Upvar_id(closure_hir, hir_p), {Deref, Field(y)} }</p>
<p>Where the place base is Upvar_id is going to be the same and we might make wrong decisions</p>



<a name="202030135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202030135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202030135">(Jun 25 2020 at 21:54)</a>:</h4>
<p>More like we might loose some capture information. We probably want some kind multimap.</p>



<a name="202030649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202030649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202030649">(Jun 25 2020 at 21:59)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/202029465">said</a>:</p>
<blockquote>
<blockquote>
<p>If an equivalent item already exists in the set, it returns false leaving the original value in the set and without altering its insertion order. Otherwise, it inserts the new item and returns true.</p>
</blockquote>
</blockquote>
<p>Actually that might alter the actual indecies of the rest.  Eg: { 'A', 'B', 'C', 'A', 'D'}. we expect 'D' to be idx 4, but it will be 3 now, because index map has no gaps.</p>
<div class="codehilite"><pre><span></span><code>Indices
The values are indexed in a compact range without holes in the range 0..self.len(). For example, the method .get_full looks up the index for a value, and the method .get_index looks up the value by index.
</code></pre></div>


<p>There are places where we use <code>.zip()</code> to put things together.  I've have looked deeply into how the other information that is being zipped together is constructed, we might have to make sure that all information is constructed from the same closure_captures or something that resemles similar ordered structure</p>



<a name="202031043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031043">(Jun 25 2020 at 22:02)</a>:</h4>
<p>Eg: <a href="https://github.com/sexxi-goose/rust/commit/f3424988c0c54d87e6e8564602d9b62af09ffd5d#diff-4f4ea23fbd57ab1f20ef778c887ab80bR931">here</a></p>



<a name="202031239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031239">(Jun 25 2020 at 22:04)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> what hir-id do you envision as the "key" for this set?</p>



<a name="202031245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031245">(Jun 25 2020 at 22:04)</a>:</h4>
<p>and why?</p>



<a name="202031265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031265">(Jun 25 2020 at 22:04)</a>:</h4>
<p>like, where are we doing looksup by key?</p>



<a name="202031356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031356">(Jun 25 2020 at 22:05)</a>:</h4>
<p>I don't understand the index set concerns</p>



<a name="202031386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031386">(Jun 25 2020 at 22:05)</a>:</h4>
<p>as long as you don't remove things from the set, I believe that the indices will be assigned just fine,</p>



<a name="202031444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031444">(Jun 25 2020 at 22:05)</a>:</h4>
<p>but I guess we should step back and better understand what exactly you are trying to do in this PR because I feel a bit confused</p>



<a name="202031450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031450">(Jun 25 2020 at 22:05)</a>:</h4>
<p>maybe we can return to this example you gave:</p>



<a name="202031500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031500">(Jun 25 2020 at 22:06)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Point</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="o">..</span><span class="p">.</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="nb">drop</span><span class="p">((</span><span class="n">p</span><span class="p">.</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="n">p</span><span class="p">.</span><span class="n">y</span><span class="p">));</span><span class="w"></span>
</code></pre></div>



<a name="202031552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031552">(Jun 25 2020 at 22:06)</a>:</h4>
<p>so here <em>today</em> we could just capture <code>p</code></p>



<a name="202031557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031557">(Jun 25 2020 at 22:06)</a>:</h4>
<p>I expect that after whatever Pr you are preparing, the same will be true</p>



<a name="202031588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031588">(Jun 25 2020 at 22:06)</a>:</h4>
<p>but we may have a data structure that <em>could accommodate</em> capturing <code>p.x</code> and <code>p.y</code> separately in the future</p>



<a name="202031602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031602">(Jun 25 2020 at 22:06)</a>:</h4>
<p>let's start there and confirm I'm correct about that :)</p>



<a name="202031726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031726">(Jun 25 2020 at 22:08)</a>:</h4>
<p>I think that is correct</p>



<a name="202031746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031746">(Jun 25 2020 at 22:08)</a>:</h4>
<p>We at somepoint need to modify what UpvarId looks like I think</p>



<a name="202031817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031817">(Jun 25 2020 at 22:09)</a>:</h4>
<p>My index concerns are mostly for the fact that we use zip() and I haven't followed the chain enough to be sure that what we expect to pair using <code>zip</code> will happen correctly, but I can see it potenitally being an issue.</p>
<p>use of zip: <a href="https://github.com/sexxi-goose/rust/commit/f3424988c0c54d87e6e8564602d9b62af09ffd5d#diff-4f4ea23fbd57ab1f20ef778c887ab80bR931">https://github.com/sexxi-goose/rust/commit/f3424988c0c54d87e6e8564602d9b62af09ffd5d#diff-4f4ea23fbd57ab1f20ef778c887ab80bR931</a></p>



<a name="202031953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202031953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202031953">(Jun 25 2020 at 22:11)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/202031265">said</a>:</p>
<blockquote>
<p>like, where are we doing looksup by key?</p>
</blockquote>
<p>Here we do lookup using the key: <a href="https://github.com/sexxi-goose/rust/blob/c3dc8c455cee65db8928913da029725046c14a1b/src/librustc_mir_build/hair/cx/expr.rs#L889">https://github.com/sexxi-goose/rust/blob/c3dc8c455cee65db8928913da029725046c14a1b/src/librustc_mir_build/hair/cx/expr.rs#L889</a></p>
<p>We can get around this by creating an UpvarId and quering if we have borrow kind info on it. But we also need the index, which I think FxIndexSet shall suffice</p>



<a name="202032134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032134">(Jun 25 2020 at 22:14)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/202031817">said</a>:</p>
<blockquote>
<p>use of zip: <a href="https://github.com/sexxi-goose/rust/commit/f3424988c0c54d87e6e8564602d9b62af09ffd5d#diff-4f4ea23fbd57ab1f20ef778c887ab80bR931">https://github.com/sexxi-goose/rust/commit/f3424988c0c54d87e6e8564602d9b62af09ffd5d#diff-4f4ea23fbd57ab1f20ef778c887ab80bR931</a></p>
</blockquote>
<p>OK, this use of zip should be ok -- in particular, that list of <code>places</code> ought to be generated precisely by iterating over the same <code>closure_captures</code> set</p>



<a name="202032174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032174">(Jun 25 2020 at 22:14)</a>:</h4>
<p>I mean that may not be the case on your branch today</p>



<a name="202032203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032203">(Jun 25 2020 at 22:14)</a>:</h4>
<p>but it should be the case</p>



<a name="202032230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032230">(Jun 25 2020 at 22:14)</a>:</h4>
<p>these links you're sending me, are they your branch?</p>



<a name="202032232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032232">(Jun 25 2020 at 22:14)</a>:</h4>
<p>or are those master</p>



<a name="202032275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032275">(Jun 25 2020 at 22:15)</a>:</h4>
<p>also sheesh why didn't we write comments on <a href="https://github.com/sexxi-goose/rust/blob/c3dc8c455cee65db8928913da029725046c14a1b/src/librustc_mir_build/hair/cx/expr.rs#L880">this fn</a> :P</p>



<a name="202032419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032419">(Jun 25 2020 at 22:16)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/202032230">said</a>:</p>
<blockquote>
<p>these links you're sending me, are they your branch?</p>
</blockquote>
<p>These are on our branch but are about a week old. We realised this while working on some issues over the last couple days.</p>



<a name="202032439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032439">(Jun 25 2020 at 22:17)</a>:</h4>
<p>OK, so, it's sort of ill-documented (sigh) but the <code>HirId</code> there appears to be the hir-id of the captured variable in the closure's owner</p>



<a name="202032467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032467">(Jun 25 2020 at 22:17)</a>:</h4>
<p>no</p>



<a name="202032475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032475">(Jun 25 2020 at 22:17)</a>:</h4>
<p>that...is maybe wrong? or maybe right. :)</p>



<a name="202032482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032482">(Jun 25 2020 at 22:17)</a>:</h4>
<p>I can't tell</p>



<a name="202032548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032548">(Jun 25 2020 at 22:18)</a>:</h4>
<p>/me goes to find where that table is constructed</p>



<a name="202032590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032590">(Jun 25 2020 at 22:18)</a>:</h4>
<p>If we are quering using the UpvarId then it's that of the declaration</p>



<a name="202032645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032645">(Jun 25 2020 at 22:19)</a>:</h4>
<p>ok, I think it is correct</p>



<a name="202032661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032661">(Jun 25 2020 at 22:19)</a>:</h4>
<p>the hir-id that is the key is the hir-id of the captured variable</p>



<a name="202032724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032724">(Jun 25 2020 at 22:20)</a>:</h4>
<p>so I guess we should discuss what we expect this data structure to eventually be. You are thinking a <code>FxIndexSet&lt;PlaceWithHirId&gt;</code>?</p>



<a name="202032766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032766">(Jun 25 2020 at 22:20)</a>:</h4>
<p>it doesn't at present encode <em>why</em>  a given place is captured</p>



<a name="202032771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032771">(Jun 25 2020 at 22:20)</a>:</h4>
<p>or rather why a given <em>variable</em> is captured</p>



<a name="202032774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032774">(Jun 25 2020 at 22:20)</a>:</h4>
<p>it just stores the <code>UpvarId</code></p>



<a name="202032797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032797">(Jun 25 2020 at 22:21)</a>:</h4>
<p>and then a different map, the <code>upvar_capture_map</code>, stores the <em>capture kind</em></p>



<a name="202032906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032906">(Jun 25 2020 at 22:22)</a>:</h4>
<p>gimme a min</p>



<a name="202032907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032907">(Jun 25 2020 at 22:22)</a>:</h4>
<p>(deleted)</p>



<a name="202032920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032920">(Jun 25 2020 at 22:22)</a>:</h4>
<p>to find the <em>span of the use</em> you have to go back to the <code>upvars_mentioned</code> query today</p>



<a name="202032937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032937">(Jun 25 2020 at 22:23)</a>:</h4>
<p>(I believe this is correct, feel free to contradict me :)</p>



<a name="202032954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202032954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202032954">(Jun 25 2020 at 22:23)</a>:</h4>
<p>I think that I might expect to refactor all the different fields above to something like this</p>



<a name="202033042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033042">(Jun 25 2020 at 22:24)</a>:</h4>
<p>Yeah, we can look up on the capture kind map to check if the variable was captured, PlaceWithHirId has the hir_id of the expr, assuming I understand what the span of the node represents <a href="https://github.com/sexxi-goose/rust/pull/18/files#diff-87528b3a624ad671b31f556cce5c612bR536">here</a> correctly</p>



<a name="202033086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033086">(Jun 25 2020 at 22:24)</a>:</h4>
<p><code>FxIndexMap&lt;hir::Place, CaptureInfo&gt;</code> where you have</p>
<div class="codehilite"><pre><span></span><code><span class="k">struct</span> <span class="nc">CaptureInfo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="sd">/// the id of some use that caused us to pick the capture-mode below</span>
<span class="w">    </span><span class="n">example_use_at</span>: <span class="nc">HirId</span><span class="p">,</span><span class="w"></span>

<span class="w">    </span><span class="sd">/// captured mode we selected</span>
<span class="w">    </span><span class="n">capture_mode</span>: <span class="nc">Mode</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="202033099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033099">(Jun 25 2020 at 22:25)</a>:</h4>
<p>however, that may not be the most convenient at this moment</p>



<a name="202033133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033133">(Jun 25 2020 at 22:25)</a>:</h4>
<p>precisely because of <a href="https://github.com/sexxi-goose/rust/blob/c3dc8c455cee65db8928913da029725046c14a1b/src/librustc_mir_build/hair/cx/expr.rs#L889">the code you referenced earlier that does lookup via the key</a></p>



<a name="202033153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033153">(Jun 25 2020 at 22:25)</a>:</h4>
<p>what that code is doing, btw, is constructing the "HAIR", which is an intermediate step between HIR and MIR</p>



<a name="202033176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033176">(Jun 25 2020 at 22:26)</a>:</h4>
<p>we are eventually going to want to change how it works</p>



<a name="202033203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033203">(Jun 25 2020 at 22:26)</a>:</h4>
<p>but the idea is something like this</p>



<a name="202033242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033242">(Jun 25 2020 at 22:26)</a>:</h4>
<p>so <a href="https://github.com/sexxi-goose/rust/blob/c3dc8c455cee65db8928913da029725046c14a1b/src/librustc_mir_build/hair/cx/expr.rs#L787">convert_path_expr</a> gets invoked on some path like <code>a</code> or <code>a::b</code> etc</p>



<a name="202033258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033258">(Jun 25 2020 at 22:26)</a>:</h4>
<p>(ah interesting I forgot that we used the term path for this...)</p>



<a name="202033293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033293">(Jun 25 2020 at 22:27)</a>:</h4>
<p>in particular it does <em>not</em> get invoked on something like <code>a.b</code>, that's a compound expression like</p>
<ul>
<li>Field (<code>b</code>)<br>
    * Path (<code>a</code>)</li>
</ul>



<a name="202033317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033317">(Jun 25 2020 at 22:27)</a>:</h4>
<p>so in our case it's basically being invoked on the variable variable that is at the start of a place expression</p>



<a name="202033338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033338">(Jun 25 2020 at 22:28)</a>:</h4>
<p>which is why we end up in the <a href="https://github.com/sexxi-goose/rust/blob/c3dc8c455cee65db8928913da029725046c14a1b/src/librustc_mir_build/hair/cx/expr.rs#L874"><code>Res::Local</code></a> arm of the match here</p>



<a name="202033381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033381">(Jun 25 2020 at 22:28)</a>:</h4>
<p>i.e., this is a reference to some local variable</p>



<a name="202033413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033413">(Jun 25 2020 at 22:28)</a>:</h4>
<p>so then we check <a href="https://github.com/sexxi-goose/rust/blob/c3dc8c455cee65db8928913da029725046c14a1b/src/librustc_mir_build/hair/cx/expr.rs#L885">is this local variable actually something we captured from some parent function</a>?</p>



<a name="202033425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033425">(Jun 25 2020 at 22:28)</a>:</h4>
<p>that will only be true if we are currently in a closure</p>



<a name="202033434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033434">(Jun 25 2020 at 22:28)</a>:</h4>
<p>otherwise, we'll get <code>upvar_index = None</code></p>



<a name="202033440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033440">(Jun 25 2020 at 22:28)</a>:</h4>
<p>make sense so far?</p>



<a name="202033471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033471">(Jun 25 2020 at 22:29)</a>:</h4>
<p>I understand the last bit, give me a second to go through the prev ones as well</p>



<a name="202033528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033528">(Jun 25 2020 at 22:29)</a>:</h4>
<p>Yeah so far so good</p>



<a name="202033586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033586">(Jun 25 2020 at 22:30)</a>:</h4>
<p><a href="https://github.com/sexxi-goose/rust/blob/c3dc8c455cee65db8928913da029725046c14a1b/src/librustc_mir_build/hair/cx/expr.rs#L901">in the case that this *is* an upvar</a>,</p>



<a name="202033625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033625">(Jun 25 2020 at 22:30)</a>:</h4>
<p>we're going to build a "HAIR" expression that converts from <code>a</code> to something like <code>self.a</code></p>



<a name="202033644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033644">(Jun 25 2020 at 22:30)</a>:</h4>
<p>where <code>self</code> is the hidden self that represents the closure struct itself</p>



<a name="202033666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033666">(Jun 25 2020 at 22:31)</a>:</h4>
<p>if this closure implements <code>Fn</code>/<code>FnMut</code>, it will take <code>&amp;self</code>/<code>&amp;mut self</code>, so the expression is more like <code>(*self).a</code></p>



<a name="202033709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033709">(Jun 25 2020 at 22:31)</a>:</h4>
<p>you see that <a href="https://github.com/sexxi-goose/rust/blob/c3dc8c455cee65db8928913da029725046c14a1b/src/librustc_mir_build/hair/cx/expr.rs#L930-L943">here</a>, where we build <code>*self</code></p>



<a name="202033765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033765">(Jun 25 2020 at 22:32)</a>:</h4>
<p>but if it is <code>FnOnce</code> (<a href="https://github.com/sexxi-goose/rust/blob/c3dc8c455cee65db8928913da029725046c14a1b/src/librustc_mir_build/hair/cx/expr.rs#L965-L970">here</a>), we just build <code>self</code></p>



<a name="202033780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033780">(Jun 25 2020 at 22:32)</a>:</h4>
<p>then we <a href="https://github.com/sexxi-goose/rust/blob/c3dc8c455cee65db8928913da029725046c14a1b/src/librustc_mir_build/hair/cx/expr.rs#L976-L978">wrap that in a field access</a></p>



<a name="202033781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033781">(Jun 25 2020 at 22:32)</a>:</h4>
<p>make sense?</p>



<a name="202033803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033803">(Jun 25 2020 at 22:32)</a>:</h4>
<p>Yeah that makes sense</p>



<a name="202033815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033815">(Jun 25 2020 at 22:32)</a>:</h4>
<p>so basically given something like <code>let x = 2; let y= || drop(x);</code>, if we are generating the HAIR for the closure <code>|| drop(x)</code>, we will generate HAIR that looks like <code>|| drop((*self).x)</code></p>



<a name="202033831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033831">(Jun 25 2020 at 22:33)</a>:</h4>
<p>yup</p>



<a name="202033834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033834">(Jun 25 2020 at 22:33)</a>:</h4>
<p>ok, so, anyway, the reason I explained all that is to say that</p>



<a name="202033838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033838">(Jun 25 2020 at 22:33)</a>:</h4>
<p>the lookup we are doing is, given the variable id for <code>x</code>, we want to find the capture information</p>



<a name="202033842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033842">(Jun 25 2020 at 22:33)</a>:</h4>
<p>if we use the <code>Place</code> as the key</p>



<a name="202033849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033849">(Jun 25 2020 at 22:33)</a>:</h4>
<p>we can still do that, but we have to construct a <code>Place</code> for <code>x</code></p>



<a name="202033872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033872">(Jun 25 2020 at 22:33)</a>:</h4>
<p>this isn't super hard I guess, we get the type of <code>x</code> <a href="https://github.com/sexxi-goose/rust/blob/c3dc8c455cee65db8928913da029725046c14a1b/src/librustc_mir_build/hair/cx/expr.rs#L924">here</a></p>



<a name="202033922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033922">(Jun 25 2020 at 22:34)</a>:</h4>
<p>so it would be a place like <code>Place { base: PlaceBase::Local(var_hir_id), base_ty: var_ty, projections: vec![] }</code> or whatever</p>



<a name="202033936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033936">(Jun 25 2020 at 22:34)</a>:</h4>
<p>(this is relying on the fact that we are only ever going to generate places as keys that are local variables)</p>



<a name="202033960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033960">(Jun 25 2020 at 22:34)</a>:</h4>
<p>and this incidentally is <em>exactly</em> why I wanted to separate <code>PlaceWithHirId</code> from <code>Place</code></p>



<a name="202033969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033969">(Jun 25 2020 at 22:34)</a>:</h4>
<p>because here we want to refer to the "place expression" in the abstract, not tied to some particular location in the code</p>



<a name="202033988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033988">(Jun 25 2020 at 22:35)</a>:</h4>
<p>make sense?</p>



<a name="202033995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202033995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202033995">(Jun 25 2020 at 22:35)</a>:</h4>
<p>Give me a min</p>



<a name="202034020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202034020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202034020">(Jun 25 2020 at 22:35)</a>:</h4>
<p>(fyi I'm going to have to sign off in a minute, getting to be dinner time here)</p>



<a name="202034115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202034115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202034115">(Jun 25 2020 at 22:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/202033086">said</a>:</p>
<blockquote>
<p><code>FxIndexMap&lt;hir::Place, CaptureInfo&gt;</code> where you have</p>
<div class="codehilite"><pre><span></span><code><span class="k">struct</span> <span class="nc">CaptureInfo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="sd">/// the id of some use that caused us to pick the capture-mode below</span>
<span class="w">    </span><span class="n">example_use_at</span>: <span class="nc">HirId</span><span class="p">,</span><span class="w"></span>

<span class="w">    </span><span class="sd">/// captured mode we selected</span>
<span class="w">    </span><span class="n">capture_mode</span>: <span class="nc">Mode</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


</blockquote>
<p>I like this and actually if we have another set of information which is this + local variables, then we can just filter on PlaceBase</p>



<a name="202034213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202034213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202034213">(Jun 25 2020 at 22:38)</a>:</h4>
<p>I'm not sure I understand what you mean by "this + local variables"</p>



<a name="202034232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202034232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202034232">(Jun 25 2020 at 22:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/202034020">said</a>:</p>
<blockquote>
<p>(fyi I'm going to have to sign off in a minute, getting to be dinner time here)</p>
</blockquote>
<p>We can continue this tomorrow or next week</p>



<a name="202034235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202034235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202034235">(Jun 25 2020 at 22:38)</a>:</h4>
<p>anyway, I think that having talked it out, I feel pretty good about using that setup that you just quoted, which I think will integrate just fine with the code above to generate the key we need etc</p>



<a name="202034243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202034243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202034243">(Jun 25 2020 at 22:39)</a>:</h4>
<p>ok, I'm going to run, hopefully this makes sense :)</p>



<a name="202034356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202034356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202034356">(Jun 25 2020 at 22:40)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/202034213">said</a>:</p>
<blockquote>
<p>I'm not sure I understand what you mean by "this + local variables"</p>
</blockquote>
<p>I mean if we have a map/list of  Places that the closure access, so that would be local variables/captures/ statics etc.  and we can just filter on PlaceBase, and it's Local and Upvar do work. And Place would also contain ids within it.</p>



<a name="202043776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202043776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202043776">(Jun 26 2020 at 01:20)</a>:</h4>
<p>Sorry for the long post. </p>
<p>TL;DR -- I don't think we are generating precise enough Place/generating Place on the correct expression.  What are your thoughts on using HirId of Expr as key to getting associated Place, making quering the ClosureCapture map easier.</p>
<p>Within TypeCheckTables related to closures we currently currently have:</p>
<ul>
<li><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckTables.html#structfield.closure_kind_origins">closure_kind_origins</a>: Records the reasons that we picked the kind of each closure; not all closures are present in the map.</li>
<li><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckTables.html#structfield.upvar_capture_map">upvar_capture_map</a>: CaptureKind</li>
<li><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckTables.html#structfield.closure_captures">closure_captures</a>: Given the closure ID this map provides the list of UpvarIDs used by it. The upvarID contains the HIR node ID and it also contains the full path leading to the member of the struct or tuple that is used instead of the entire variable.</li>
</ul>
<p>The documentation is conflicting about the var_path in UpvarId, <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.UpvarId.html
[expr_use_visitor#walk_captures]:%20https://github.com/rust-lang/rust/blob/master/src/librustc_typeck/expr_use_visitor.rs#L543">UpvarId</a> documentation says </p>
<blockquote>
<p>Upvars do not get their own <code>NodeId</code>. Instead, we use the pair of the original var ID (that is, the root variable that is referenced by the upvar) and the ID of the closure expression.</p>
</blockquote>
<p>However based on <a href="https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_passes/upvars.rs.html#82">https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_passes/upvars.rs.html#82</a> -- which is then used to construct closure_captures</p>
<p>and </p>
<blockquote>
<p>nikomatsakis: in particular it does not get invoked on something like a.b, that's a compound expression like</p>
<p>Field (b)</p>
<ul>
<li>Path (a)<br>
nikomatsakis: so in our case it's basically being invoked on the variable variable that is at the start of a place expression</li>
</ul>
<p>nikomatsakis: which is why we end up in the Res::Local arm of the match here</p>
<p>nikomatsakis: i.e., this is a reference to some local variable</p>
</blockquote>
<p>That we store the root variable and not the actual path in our tables today. </p>
<p>This derailed from what I wanted to mention</p>
<ul>
<li>I don't think closure_kind_origins need to change</li>
<li>We probably want upvar_capture_map and closure_captures to change to something like what you suggested, but more easily queriable, because we might not have access to the Place everywhere -- the current suggestion might require computing projections again and PartialEq might not be correct in all place. I like the quering span/hir_id for the place rather than having a compelete composites (PlaceWithHirId).</li>
<li>What I was thinking and trying to express with the "this + local variables" was that, what do you think about storing information in a way that expresses all the <code>Place</code>s that a closure can access. These would be the params/local variables or captured values. Do closures think of static variables as captures or still as static values? I'd assume the former, but I can be wrong.</li>
</ul>
<p>That said looking into how upvars_mentioned is created, I think that would require changes too because we don't express the actual fields -- to be able to generate a Place that expresses the access (eg: a.b.c) precisely.</p>
<p>This will cause a problem in <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_typeck/expr_use_visitor.rs#L543">expr_use_visitor#walk-captures</a>, as it generates places for borrow/consume direcrly from upvars_mentioned. Or we can make walk_captures(rename to walk_closures), walk all the expressions within the closure and make decisions.</p>
<p>From what I have looked at so far, anything that's been used today for generating information related to closures, I don't see anything that expresses the precise kind of access other than HirExpr, which currently is ignored in walk_captures.</p>
<p>Also if we use HirExpr or the HirId associated with the HirExpr, can we have map that to a Place to make querying even easier? I understand  normalization might be an issue and this might not depict the state clearly, but I think we will have the issue when using Place as a key aswell.</p>



<a name="202139625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202139625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202139625">(Jun 26 2020 at 20:36)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> </p>
<p>So, I'm not sure to what extent you are trying to solve the <em>immediate</em> problem (where the place is always a variable) versus preparing for the future (where the place may not be a variable). I'm not sure the best way to handle the future. I think it'd be fine if, for the current stage where it's always a variable, we index the map by the <code>HirId</code>.</p>
<p>I sort of suspect that the "right" data structure for the future might be a kind of tree. The trick is that we we have a HIR expression like <code>a.b.c</code> and some 'prefix' of it needs to be replaced by a reference to an upvar, but that prefix isn't always just the local variable anymore. I was kind of putting off thinking about the best way to do that matching but I think it will probably require changes to the <code>closure_captures</code> map ultimately.</p>



<a name="202139656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202139656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202139656">(Jun 26 2020 at 20:37)</a>:</h4>
<blockquote>
<p>That said looking into how upvars_mentioned is created, I think that would require changes too because we don't express the actual fields -- to be able to generate a Place that expresses the access (eg: a.b.c) precisely.</p>
</blockquote>
<p>I don't really understand what this means though. I don't expect <code>upvars_mentioned</code> to ever change in any way from what it does now -- just return a list of variables.</p>



<a name="202139688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202139688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202139688">(Jun 26 2020 at 20:37)</a>:</h4>
<p>Regarding the documentation, I agree it is out of date, I think that code changed. I believe we used to have more than one id for upvars, but it got refactored and cleaned up at some point to just use the <code>HirId</code> from the enclosing function.</p>



<a name="202139801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202139801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202139801">(Jun 26 2020 at 20:38)</a>:</h4>
<blockquote>
<p>This will cause a problem in expr_use_visitor#walk-captures, as it generates places for borrow/consume direcrly from upvars_mentioned. Or we can make walk_captures(rename to walk_closures), walk all the expressions within the closure and make decisions.</p>
</blockquote>
<p>I think this is ok -- the expr use visitor is going to be the thing that we use to figure out which places we capture in the first place.</p>



<a name="202139833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202139833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202139833">(Jun 26 2020 at 20:39)</a>:</h4>
<blockquote>
<p>I don't think we are generating precise enough Place/generating Place on the correct expression.</p>
</blockquote>



<a name="202139867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202139867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202139867">(Jun 26 2020 at 20:39)</a>:</h4>
<p>by this are you just pointing out that the HIR <code>Place</code>  as defined today doesn't contain all the information we will eventually need (i.e., it is missing specifics about many kinds of projections)?</p>



<a name="202139869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202139869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202139869">(Jun 26 2020 at 20:39)</a>:</h4>
<p>or something else</p>



<a name="202140052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202140052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202140052">(Jun 26 2020 at 20:41)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/202139867">said</a>:</p>
<blockquote>
<p>by this are you just pointing out that the HIR <code>Place</code>  as defined today doesn't contain all the information we will eventually need (i.e., it is missing specifics about many kinds of projections)?</p>
</blockquote>
<p>With this I meant that we currently call cat_res from expr_use_visitor on the variable hir_id today that returns a Place that points just to the root variable.</p>



<a name="202140589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202140589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202140589">(Jun 26 2020 at 20:47)</a>:</h4>
<p>is that a problem?</p>



<a name="202141131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202141131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202141131">(Jun 26 2020 at 20:53)</a>:</h4>
<p>If I understand correctly we are saying categorize(a), and we need to find a way of saying categorize(a.b.c) .</p>
<p>Basically we need to modify expr_use_visitor to walk the tree and this confirms that: </p>
<blockquote>
<p>I think this is ok -- the expr use visitor is going to be the thing that we use to figure out which places we capture in the first place.</p>
</blockquote>



<a name="202141461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202141461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202141461">(Jun 26 2020 at 20:56)</a>:</h4>
<p>Basically no where that I have seen so far until the typechk layer we really store something that expresses (outside of an actualy expression) the actual access <code>a.b.c</code> and therfore it won't be categorized as <code>a.b.c</code>.</p>



<a name="202141587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202141587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202141587">(Jun 26 2020 at 20:57)</a>:</h4>
<p>Hmm, so <a href="https://github.com/rust-lang/rust/blob/7750c3d46bc19784adb1ee6e37a5ec7e4cd7e772/src/librustc_typeck/mem_categorization.rs#L387-L391">this code in the <code>mem_categorizaton</code> module</a> is the one that creates a <code>Place</code> that refers to a field</p>



<a name="202141694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202141694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202141694">(Jun 26 2020 at 20:58)</a>:</h4>
<p>But when we see a closure expr, we woul call <a href="https://github.com/rust-lang/rust/blob/7750c3d46bc19784adb1ee6e37a5ec7e4cd7e772/src/librustc_typeck/expr_use_visitor.rs#L310">https://github.com/rust-lang/rust/blob/7750c3d46bc19784adb1ee6e37a5ec7e4cd7e772/src/librustc_typeck/expr_use_visitor.rs#L310</a></p>



<a name="202141757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202141757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202141757">(Jun 26 2020 at 20:59)</a>:</h4>
<p>Yes. We'll eventually be changing that.</p>



<a name="202141787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202141787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202141787">(Jun 26 2020 at 20:59)</a>:</h4>
<p>it will not use <code>upvars_mentioned</code>, I don't think, it will probably use <code>self.mc.tables.closure_captures</code></p>



<a name="202141796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202141796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202141796">(Jun 26 2020 at 20:59)</a>:</h4>
<p>Yeah, that's what i was getting at. That part needs to be reworked as well.</p>



<a name="202141855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202141855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202141855">(Jun 26 2020 at 21:00)</a>:</h4>
<p>and indeed we could rewrite it now I guess</p>



<a name="202141890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202141890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202141890">(Jun 26 2020 at 21:00)</a>:</h4>
<p>though i'm not sure if <code>self.mc.tables</code> etc will be updated at the right time</p>



<a name="202141943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202141943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202141943">(Jun 26 2020 at 21:01)</a>:</h4>
<p>Right before this gets called, we currently generate closure_capture in check/upvars.rs</p>



<a name="202141956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202141956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202141956">(Jun 26 2020 at 21:01)</a>:</h4>
<p>OK</p>



<a name="202141969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202141969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202141969">(Jun 26 2020 at 21:01)</a>:</h4>
<p>Makes sense since we are reading other similar state</p>



<a name="202141977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202141977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202141977">(Jun 26 2020 at 21:01)</a>:</h4>
<p>e.g. the "capture modes" etc</p>



<a name="202141986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202141986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202141986">(Jun 26 2020 at 21:01)</a>:</h4>
<p>so yeah, we'll rewrite that to read from the "in-progress tables" that we're generating</p>



<a name="202142012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142012">(Jun 26 2020 at 21:01)</a>:</h4>
<p>which will make use of the <code>Place</code> that we record for each captured upvar</p>



<a name="202142040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142040">(Jun 26 2020 at 21:02)</a>:</h4>
<p>do you see a problem with that?</p>



<a name="202142205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142205">(Jun 26 2020 at 21:03)</a>:</h4>
<p>I don't think that works because currently it's generated using upvars_mentioend.</p>
<p>I was hoping to generate it on the fly based on the delegate callback from expr_use_visitor</p>



<a name="202142212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142212">(Jun 26 2020 at 21:03)</a>:</h4>
<p>So something like this: <a href="https://github.com/rust-lang/rust/compare/master...sexxi-goose:closure_capture_places#diff-193820a23727493def60049c0b6af47eR468">https://github.com/rust-lang/rust/compare/master...sexxi-goose:closure_capture_places#diff-193820a23727493def60049c0b6af47eR468</a></p>



<a name="202142317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142317">(Jun 26 2020 at 21:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/202142205">said</a>:</p>
<blockquote>
<p>I don't think that works because currently it's generated using upvars_mentioend.</p>
</blockquote>
<p>I was presuming we would change that. Are you saying that changing it to not use upvars_mentioned won't work?</p>



<a name="202142355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142355">(Jun 26 2020 at 21:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/202142212">said</a>:</p>
<blockquote>
<p>So something like this: <a href="https://github.com/rust-lang/rust/compare/master...sexxi-goose:closure_capture_places#diff-193820a23727493def60049c0b6af47eR468">https://github.com/rust-lang/rust/compare/master...sexxi-goose:closure_capture_places#diff-193820a23727493def60049c0b6af47eR468</a></p>
</blockquote>
<p>that...looks wrong to me</p>



<a name="202142365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142365">(Jun 26 2020 at 21:05)</a>:</h4>
<p>well, not <em>wrong</em></p>



<a name="202142366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142366">(Jun 26 2020 at 21:05)</a>:</h4>
<p>We would have to change it to not sure upvars_mentioned, but we can't use closure_captures directly</p>



<a name="202142370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142370">(Jun 26 2020 at 21:05)</a>:</h4>
<p>but premature :)</p>



<a name="202142399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142399">(Jun 26 2020 at 21:05)</a>:</h4>
<p>what I mean is</p>



<a name="202142407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142407">(Jun 26 2020 at 21:05)</a>:</h4>
<p>I think we need to collect all the places, so that is right</p>



<a name="202142451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142451">(Jun 26 2020 at 21:06)</a>:</h4>
<p>oh, I see, <code>self.closure_captures</code>... well, maybe right yeah :)</p>



<a name="202142471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142471">(Jun 26 2020 at 21:06)</a>:</h4>
<p>I've not given a ton of thought to how we're going to do the "collecting and collating" of places</p>



<a name="202142484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142484">(Jun 26 2020 at 21:06)</a>:</h4>
<p>but I feel like we don't have to do that yet</p>



<a name="202142556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142556">(Jun 26 2020 at 21:07)</a>:</h4>
<p>I sort of expected us to just synthesize the contents of the new <code>closure_captures</code> field at the same place that we currently generate the "capture modes" and what not for the closure</p>



<a name="202142641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142641">(Jun 26 2020 at 21:08)</a>:</h4>
<p>I guess <a href="https://github.com/sexxi-goose/rust/blob/047c71caba37df9cb7d81962fea19b8525cdcd7a/src/librustc_typeck/check/upvar.rs#L153">around here</a></p>



<a name="202142699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142699">(Jun 26 2020 at 21:08)</a>:</h4>
<p>Yup, by that point we would've walked the closure</p>



<a name="202142710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142710">(Jun 26 2020 at 21:08)</a>:</h4>
<p>basically <a href="https://github.com/sexxi-goose/rust/blob/047c71caba37df9cb7d81962fea19b8525cdcd7a/src/librustc_typeck/check/upvar.rs#L175">this line</a> I guess but we would do it differently, creating the new data structure</p>



<a name="202142729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142729">(Jun 26 2020 at 21:09)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/202142699">said</a>:</p>
<blockquote>
<p>Yup, by that point we would've walked the closure</p>
</blockquote>
<p>I don't think so</p>



<a name="202142744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142744">(Jun 26 2020 at 21:09)</a>:</h4>
<p>we will have walked the <em>body</em> of the closure</p>



<a name="202142751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142751">(Jun 26 2020 at 21:09)</a>:</h4>
<p>but not the closure expression itself, which is part of the owner's body</p>



<a name="202142759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142759">(Jun 26 2020 at 21:09)</a>:</h4>
<p>we do the inference "inside out", no?</p>



<a name="202142864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142864">(Jun 26 2020 at 21:10)</a>:</h4>
<p>that's what <a href="https://github.com/sexxi-goose/rust/blob/047c71caba37df9cb7d81962fea19b8525cdcd7a/src/librustc_typeck/check/upvar.rs#L58-L74">this visitor</a> does -- it just walks the body of the fn and analyzes closures within</p>



<a name="202142868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142868">(Jun 26 2020 at 21:10)</a>:</h4>
<div class="codehilite"><pre><span></span><code>    fn visit_expr(&amp;mut self, expr: &amp;&#39;tcx hir::Expr&lt;&#39;tcx&gt;) {
        if let hir::ExprKind::Closure(cc, _, body_id, _, _) = expr.kind {
            let body = self.fcx.tcx.hir().body(body_id);
            self.visit_body(body);
            self.fcx.analyze_closure(expr.hir_id, expr.span, body, cc);
        }

        intravisit::walk_expr(self, expr);
    }
</code></pre></div>



<a name="202142880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142880">(Jun 26 2020 at 21:10)</a>:</h4>
<p>yeah, but at this point we are not using the expr-use-visitor at all</p>



<a name="202142885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142885">(Jun 26 2020 at 21:10)</a>:</h4>
<p>that's just a regular visitor</p>



<a name="202142900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142900">(Jun 26 2020 at 21:11)</a>:</h4>
<p>the ExprUseVisitor is invoked <a href="https://github.com/sexxi-goose/rust/blob/047c71caba37df9cb7d81962fea19b8525cdcd7a/src/librustc_typeck/check/upvar.rs#L145-L152">here</a></p>



<a name="202142912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142912">(Jun 26 2020 at 21:11)</a>:</h4>
<p>Yeah, but the at the this line: <a href="https://github.com/sexxi-goose/rust/blob/047c71caba37df9cb7d81962fea19b8525cdcd7a/src/librustc_typeck/check/upvar.rs#L153">https://github.com/sexxi-goose/rust/blob/047c71caba37df9cb7d81962fea19b8525cdcd7a/src/librustc_typeck/check/upvar.rs#L153</a></p>



<a name="202142915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142915">(Jun 26 2020 at 21:11)</a>:</h4>
<p>which is part of this call:</p>
<blockquote>
<div class="codehilite"><pre><span></span><code>        self.fcx.analyze_closure(expr.hir_id, expr.span, body, cc);
</code></pre></div>


</blockquote>



<a name="202142925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142925">(Jun 26 2020 at 21:11)</a>:</h4>
<p>we consume the body of the closure</p>



<a name="202142933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142933">(Jun 26 2020 at 21:11)</a>:</h4>
<p>yes?</p>



<a name="202142939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142939">(Jun 26 2020 at 21:11)</a>:</h4>
<p>would that not being traverssing the closure body</p>



<a name="202142951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142951">(Jun 26 2020 at 21:11)</a>:</h4>
<p>yes, but that doesn't invoke walk_captures</p>



<a name="202142956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142956">(Jun 26 2020 at 21:11)</a>:</h4>
<p>and the body tells us what's being captures?</p>



<a name="202142962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202142962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202142962">(Jun 26 2020 at 21:11)</a>:</h4>
<p>yes</p>



<a name="202143038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143038">(Jun 26 2020 at 21:12)</a>:</h4>
<p>so e.g. if we have</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">c1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">c2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">           </span><span class="nb">drop</span><span class="p">(</span><span class="n">a</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="p">};</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="202143062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143062">(Jun 26 2020 at 21:12)</a>:</h4>
<p>in the outer walk, we will walk the body, and we will first encounter c1, which walks its body, which encounters c2</p>



<a name="202143069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143069">(Jun 26 2020 at 21:12)</a>:</h4>
<p>then we will analyze the body of c2, which is <code>{ drop(a); }</code></p>



<a name="202143102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143102">(Jun 26 2020 at 21:12)</a>:</h4>
<p>we'll see that it uses <code>a</code> etc</p>



<a name="202143135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143135">(Jun 26 2020 at 21:13)</a>:</h4>
<p>when it's done, we'll fill in the <code>TypeckTables</code> with information about <code>c2</code> -- in particular, we would fill in this new <code>closure_captures</code> hashmap we are talking about</p>



<a name="202143163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143163">(Jun 26 2020 at 21:13)</a>:</h4>
<p>so that it records the <code>Place</code> for <code>a</code> etc</p>



<a name="202143189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143189">(Jun 26 2020 at 21:13)</a>:</h4>
<p>then we would continue with that outer visit. now that we have visited the body of c1, we would analyze the body.</p>



<a name="202143206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143206">(Jun 26 2020 at 21:14)</a>:</h4>
<p>the body of c1 is <code>{ let c2 = || /* opaque */; }</code></p>



<a name="202143260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143260">(Jun 26 2020 at 21:14)</a>:</h4>
<p>at <em>this</em> point, as we walk the <code>|| ...</code> expression,</p>



<a name="202143282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143282">(Jun 26 2020 at 21:14)</a>:</h4>
<p><em>that</em> is where the <code>ExprUseVisitor</code> code that invokes <code>walk_captures</code> gets invoked</p>



<a name="202143312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143312">(Jun 26 2020 at 21:14)</a>:</h4>
<p>the idea is that the closure expression corresponds to creating the closure structure, so its accesses are to "capture" the various upvars that it refers to</p>



<a name="202143314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143314">(Jun 26 2020 at 21:14)</a>:</h4>
<p>I see</p>



<a name="202143346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143346">(Jun 26 2020 at 21:15)</a>:</h4>
<p>but by this time the <code>closure_captures</code> data for <code>c2</code> is available to us (but not <code>c1</code>, but we don't need it yet)</p>



<a name="202143359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143359">(Jun 26 2020 at 21:15)</a>:</h4>
<p>in fact, we'll never use the data for <code>c1</code></p>



<a name="202143366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143366">(Jun 26 2020 at 21:15)</a>:</h4>
<p>it's only relevant for nested closures</p>



<a name="202143370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143370">(Jun 26 2020 at 21:15)</a>:</h4>
<p>I mean, we will use it when we build the MIR etc</p>



<a name="202143378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143378">(Jun 26 2020 at 21:15)</a>:</h4>
<p>but not during this analysis :)</p>



<a name="202143400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143400">(Jun 26 2020 at 21:15)</a>:</h4>
<p>this is because we never analyze the body of the outer function, since it doesn't capture anything</p>



<a name="202143547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143547">(Jun 26 2020 at 21:16)</a>:</h4>
<p>Give me a couple mins to process some of this</p>



<a name="202143994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202143994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202143994">(Jun 26 2020 at 21:20)</a>:</h4>
<p>Overall the flow would be </p>
<ul>
<li>instravist on foo, see a closure expr c1</li>
<li>Visits the body of c1 // (2)</li>
<li>instravisit on c1, sees a closure expr c2</li>
<li>Visits the body c2  // (1)</li>
<li>analyses the closure c2  and hence the captures (1')</li>
<li>c2 intravisit finishes</li>
<li>analyses the closure c1 and hence the captures (2')</li>
<li>c1 intravisit finishes </li>
<li>foo intravisit finishes</li>
</ul>



<a name="202144014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202144014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202144014">(Jun 26 2020 at 21:20)</a>:</h4>
<p>When I say intravisit finishes it's for parts we are concerned with atm, analyse would be expr_use_visitor</p>



<a name="202144407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202144407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202144407">(Jun 26 2020 at 21:24)</a>:</h4>
<p>So somewhere at (1) or (1') line below we will figure out that c2 is consuming a.</p>



<a name="202144481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202144481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202144481">(Jun 26 2020 at 21:25)</a>:</h4>
<p>1' would make more sense because we are categorizing the use in there.</p>



<a name="202144974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202144974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202144974">(Jun 26 2020 at 21:30)</a>:</h4>
<p>that sounds right</p>



<a name="202145182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202145182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202145182">(Jun 26 2020 at 21:32)</a>:</h4>
<p>something like this, with nesting :)</p>
<div class="codehilite"><pre><span></span><code>| visit body of foo
| | visit body of c1
| | | visit closure c2
| | | | visit body of c2 (does nothing)
| | | | analyze body of c2, producing closure_captures[c2]
| | analyze body of c1, reading closure_captures[c2], producing closure_captures[c1]
</code></pre></div>



<a name="202145241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202145241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202145241">(Jun 26 2020 at 21:33)</a>:</h4>
<p>Okay, I has an incorrect understanding of how we were walking. </p>
<p>Basically walk_captures is called for the the closure c2 from c1. By the time we call anaylse closure on <code>c1</code>  <a href="https://github.com/sexxi-goose/rust/blob/047c71caba37df9cb7d81962fea19b8525cdcd7a/src/librustc_typeck/check/upvar.rs#L69">here</a> we would've processed the closure_captures on c2</p>



<a name="202145381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202145381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202145381">(Jun 26 2020 at 21:35)</a>:</h4>
<p>yes</p>



<a name="202145392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202145392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202145392">(Jun 26 2020 at 21:35)</a>:</h4>
<p>exactly</p>



<a name="202145395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202145395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202145395">(Jun 26 2020 at 21:35)</a>:</h4>
<p>(it's subtle indeed)</p>



<a name="202146227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202146227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202146227">(Jun 26 2020 at 21:45)</a>:</h4>
<p>And similar thing happens here: </p>
<p><a href="https://github.com/sexxi-goose/rust/blob/047c71caba37df9cb7d81962fea19b8525cdcd7a/src/librustc_typeck/check/upvar.rs#L112">https://github.com/sexxi-goose/rust/blob/047c71caba37df9cb7d81962fea19b8525cdcd7a/src/librustc_typeck/check/upvar.rs#L112</a></p>
<p>We initialize all upvars based on information from closure expression (I'm assuming if it's marked mut or move). Then when we walk the tree we consume or borrow each expr and if we say another closure within we must have already processed it, so we can read information about it directly from typeck tables</p>



<a name="202146253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202146253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202146253">(Jun 26 2020 at 21:45)</a>:</h4>
<p>Where technically we can use closure_captures again</p>



<a name="202146328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202146328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202146328">(Jun 26 2020 at 21:46)</a>:</h4>
<p>right</p>



<a name="202146338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202146338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202146338">(Jun 26 2020 at 21:46)</a>:</h4>
<p>so <em>that</em> logic may have to change sooner or later</p>



<a name="202146721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202146721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202146721">(Jun 26 2020 at 21:51)</a>:</h4>
<p>So I expect atleast <a href="https://github.com/rust-lang/project-rfc-2229/issues/5">#5</a> (Type info in projections) to have a PR open next week, fair likehood on getting <a href="https://github.com/rust-lang/project-rfc-2229/issues/2">#2</a>/#1 (field, index, subslice) done soon as well. That basically means we have <a href="https://github.com/rust-lang/project-rfc-2229/issues/7">#7</a> as our main next ticket. This will be followed by <a href="https://github.com/rust-lang/project-rfc-2229/issues/4">#4</a></p>



<a name="202146759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202146759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202146759">(Jun 26 2020 at 21:51)</a>:</h4>
<p>great</p>



<a name="202146813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202146813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202146813">(Jun 26 2020 at 21:52)</a>:</h4>
<p>in general, this flow is working for you all? (I.e., you're getting answers to your questions in a timely fashion :)</p>



<a name="202146843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202146843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202146843">(Jun 26 2020 at 21:52)</a>:</h4>
<p>Yeah, I think this going way better than we could've asked for, thank you so much</p>



<a name="202146888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202146888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202146888">(Jun 26 2020 at 21:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/202146721">said</a>:</p>
<blockquote>
<p>So I expect atleast <a href="https://github.com/rust-lang/project-rfc-2229/issues/5">#5</a> (Type info in projections) to have a PR open next week, fair likehood on getting <a href="https://github.com/rust-lang/project-rfc-2229/issues/2">#2</a>/#1 (field, index, subslice) done soon as well. That basically means we have <a href="https://github.com/rust-lang/project-rfc-2229/issues/7">#7</a> as our main next ticket. This will be followed by <a href="https://github.com/rust-lang/project-rfc-2229/issues/4">#4</a></p>
</blockquote>
<p>My point with that was that we should probably decide how the key  and the typechk tables look sooner than later</p>



<a name="202146911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202146911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202146911">(Jun 26 2020 at 21:53)</a>:</h4>
<p>why don't we discuss that in the next sync meeting...?</p>



<a name="202146927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/202146927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#202146927">(Jun 26 2020 at 21:53)</a>:</h4>
<p>Yup</p>



<a name="203251831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/203251831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#203251831">(Jul 08 2020 at 10:29)</a>:</h4>
<p>Currently when we initials the upvars_capture_map (upvarid -&gt; capture kind), the capture kind is initialized with a new region for each root variable. </p>
<p>Now <br>
a) We will be initializing capture information as well process expressions in InferBorrowKind<br>
b) if I understand correctly we will be creating a new Region for ecah of the different Place that use the same root variable. How does the origin fit in with that when we call </p>
<div class="codehilite"><pre><span></span><code>let origin = UpvarRegion(upvar_id, access_span);
let upvar_region = self.next_region_var(origin);
</code></pre></div>


<p>because now multiple places share the same upvar_id. </p>
<p>This is where I plan on init'ing capture_info for each capture: <a href="https://github.com/rust-lang/rust/commit/6efe37e3926f23a2b57eeb96f4ed2fe854002bcf#diff-193820a23727493def60049c0b6af47eR603">https://github.com/rust-lang/rust/commit/6efe37e3926f23a2b57eeb96f4ed2fe854002bcf#diff-193820a23727493def60049c0b6af47eR603</a><br>
(note this is just a very initial draft sort of)</p>



<a name="203271590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/203271590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#203271590">(Jul 08 2020 at 14:09)</a>:</h4>
<p>Hmm, I'm not sure if those regions are still relevant, to be honest. Also, why do you say that multiple places share the same <code>upvar_id</code>?</p>



<a name="203271618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/203271618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#203271618">(Jul 08 2020 at 14:09)</a>:</h4>
<p>I guess I have to look into <code>upvar_region</code> but I wouldn't be surprised if it can be removed</p>



<a name="203289315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/203289315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#203289315">(Jul 08 2020 at 16:23)</a>:</h4>
<p>UpvarId is basically (def Id, root var hir Id). So captured places like a.b, a.b.c, a.x will have the same UpvarId because same root variable (assuming all of these were captured in the same closure)</p>



<a name="203311250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/203311250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#203311250">(Jul 08 2020 at 19:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/203271618">said</a>:</p>
<blockquote>
<p>I guess I have to look into <code>upvar_region</code> but I wouldn't be surprised if it can be removed</p>
</blockquote>
<p>We use region for defining capture via borrow: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.UpvarBorrow.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.UpvarBorrow.html</a></p>



<a name="203311937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/203311937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#203311937">(Jul 08 2020 at 19:33)</a>:</h4>
<p>though we overwrite it when finishing typeck: <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_typeck/check/writeback.rs#L328">https://github.com/rust-lang/rust/blob/master/src/librustc_typeck/check/writeback.rs#L328</a></p>



<a name="203328413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/203328413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#203328413">(Jul 08 2020 at 21:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/203289315">said</a>:</p>
<blockquote>
<p>UpvarId is basically (def Id, root var hir Id). So captured places like a.b, a.b.c, a.x will have the same UpvarId because same root variable (assuming all of these were captured in the same closure)</p>
</blockquote>
<p>it is not obvious to me that we will still be using upvar-id by the time we finish this change, I guess</p>



<a name="203328433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/203328433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#203328433">(Jul 08 2020 at 21:52)</a>:</h4>
<p>I'm not even sure if we need it <em>now</em>, it might be something we could refactor away with relative ease</p>



<a name="203328477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/203328477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#203328477">(Jul 08 2020 at 21:53)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/Typecheck.20tables.20using.20Places/near/203311937">said</a>:</p>
<blockquote>
<p>though we overwrite it when finishing typeck: <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_typeck/check/writeback.rs#L328">https://github.com/rust-lang/rust/blob/master/src/librustc_typeck/check/writeback.rs#L328</a></p>
</blockquote>
<p>exactly, this is why I was saying I'm not sure how imp't it is</p>



<a name="203328486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/203328486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#203328486">(Jul 08 2020 at 21:53)</a>:</h4>
<p>we may still need it for a bit</p>



<a name="203328624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/203328624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#203328624">(Jul 08 2020 at 21:54)</a>:</h4>
<p>Currently we're trying to build the capture_information in parallel and see if can slowly remove the existing structures</p>



<a name="203328651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/203328651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#203328651">(Jul 08 2020 at 21:55)</a>:</h4>
<p>So maybe that will answer that bit</p>



<a name="203401666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/203401666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#203401666">(Jul 09 2020 at 15:36)</a>:</h4>
<p>OK, let me know if there are any further questions</p>



<a name="203424507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/203424507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#203424507">(Jul 09 2020 at 18:51)</a>:</h4>
<p>Will do, thanks</p>



<a name="205085676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/205085676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#205085676">(Jul 27 2020 at 06:43)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281950">Aman Arora</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/meeting.202020-07-21/near/205064007">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/189812-t-compiler.2Fwg-rfc-2229/topic/meeting.202020-07-21/near/204593541">said</a>:</p>
<blockquote>
<p>Regarding the bridge: OK, that sounds reasonable. One thing to note is that we are <em>always</em> going to have to support the current mode of 'just capture the root variable'. My expectation is that we'll phase in this new RFC along an edition boundary, so we'll still have to support the old mode. But I think this isn't a problem, it comes down to the question of "truncating" the place to just the root variable, as you already noted.</p>
</blockquote>
<p>We can't just drop projections,  it is used to figure out UniqueImmBorrow <br>
<a href="https://github.com/rust-lang/rust/blob/222d2508375a363be7a4f6ded3c9bd7be0803d19/src/librustc_typeck/check/upvar.rs#L322">https://github.com/rust-lang/rust/blob/222d2508375a363be7a4f6ded3c9bd7be0803d19/src/librustc_typeck/check/upvar.rs#L322</a></p>
</blockquote>
<p>(Semi-hacky) work around could be when we drop the projections and how we read from the capture information that is currently being built in InferBorrowKind. </p>
<ul>
<li>So if we need to read the capture information when handling a Place, we read using a Place that doesn't contain projections</li>
<li>When we update the capture information we add after dropping the place.</li>
</ul>
<p>This mimics what the current behaviour is because we currently store information with var hir id as the key and use Place within InferBorrowKind without ever modifying it</p>



<a name="205145014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck%20tables%20using%20Places/near/205145014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189812-t-compiler/wg-rfc-2229/topic/Typecheck.20tables.20using.20Places.html#205145014">(Jul 27 2020 at 17:25)</a>:</h4>
<p>I'm not sure what's the best way to go about it, but whatever we do it doesn't seem too difficult to "reduce" a use to the base variable -- but you're right that we have to examine the projections at some point in order to determine the "capture mode"</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>